package pe.bn.WSServiceHost.serHost.model;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.ResourceBundle;

import pe.bn.WSServiceHost.serHost.interactive.WSData;


public class HeadRequest extends WSData {
	public static int TIPO_TRANSACCION_HP = 1;
	public static int TIPO_TRANSACCION_CH = 2;
	public void init(){
		this.campos = new Campo[17];
		try {
				this.campos[0]		= 	new Campo("LONG",			Campo.NUM_CODIGO,4);
				this.campos[1]		=	new Campo("TRANS",			Campo.CHAR_LEFT,4);
				this.campos[2]		=	new Campo("TIMESTAMP",		Campo.CHAR_LEFT,26);
				this.campos[3]		=	new Campo("COD-TRAN",		Campo.CHAR_LEFT,4);
				this.campos[4]		=	new Campo("COD-USER",		Campo.CHAR_LEFT,6);
				this.campos[5]		=	new Campo("COD-RET",		Campo.CHAR_LEFT,5);
				this.campos[6]		=	new Campo("DES-RET",		Campo.CHAR_LEFT,25);
				this.campos[7]		=	new Campo("COD-CANAL",		Campo.CHAR_LEFT,4);
				this.campos[8]		=	new Campo("COD-TERM",		Campo.CHAR_LEFT,6);
				this.campos[9]		=	new Campo("COD-ACCION",		Campo.CHAR_LEFT,2);
				this.campos[10]		=	new Campo("COD-OFIC",		Campo.NUM_CODIGO,4);
				this.campos[11]		=	new Campo("CEN-HIPO",		Campo.NUM_CODIGO,6);
				this.campos[12]		=	new Campo("VAR-1",			Campo.CHAR_LEFT,10);
				this.campos[13]		=	new Campo("VAR-2",			Campo.CHAR_LEFT,10);
				this.campos[14]		=	new Campo("COD-RET-LOG",	Campo.CHAR_LEFT,5);
				this.campos[15]		=	new Campo("DES-RET-LOG",	Campo.CHAR_LEFT,22);
				this.campos[16]		=	new Campo("CONTROL",		Campo.CHAR_LEFT,100);
			
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public HeadRequest(
				//String 	lon,
				//String 	trans,
				//String 	timestamp,
				String 	cod_tran,
				String 	cod_user,
				//String 	cod_ret,
				//String 	des_ret,
				//String 	cod_canal,
				//String 	cod_term,
				//String 	cod_accion,
				String 	cod_ofic,
				String 	cen_hipo,
				//String 	var_1,
				//String 	var_2,
				//String 	cod_ret_log,
				//String 	des_ret_log,
				String 	control
				,int tipo) throws Exception {
		
		init();

	    ResourceBundle rb = ResourceBundle.getBundle("parametro");
	    String longs = rb.getString("SOAPlongs");
	    
	    String trans = "";
	    if(TIPO_TRANSACCION_CH == tipo){
	    	trans = rb.getString("SOAPtrans");
	    }else{
	    	trans = rb.getString("SOAPtransPago");	
	    }
	    
	    String canal = rb.getString("SOAPcanal");
	    String accion = rb.getString("SOAPaccion");
	    String var_1 = rb.getString("SOAPvar_1");
	    String var_2 = rb.getString("SOAPvar_2");
	    String term = rb.getString("SOAPterm");
	    String valorIni = rb.getString("SOAPValorIni");
	    
		this.campos[0].setString(longs);
		this.campos[1].setString(trans);
		
		//Obteniendo el timestamp
		String 	timestamp = "";
		Calendar fecha = Calendar.getInstance();
		SimpleDateFormat formato =  new SimpleDateFormat("yyyy-MM-dd-HH.mm.ss.SSSSSS");
		timestamp = formato.format(fecha.getTime());
		this.campos[2].setString(timestamp);
		this.campos[3].setString(cod_tran);
		this.campos[4].setString(cod_user);
		this.campos[5].setString(valorIni);
		//this.campos[6].set("");
		this.campos[7].setString(canal);
		this.campos[8].setString(term);
		this.campos[9].setString(accion);
		this.campos[10].setString(cod_ofic);
		this.campos[11].setString(cen_hipo);
		this.campos[12].setString(var_1);
		this.campos[13].setString(var_2);
		//this.campos[14].set("");
		//this.campos[15].set("");
		this.campos[16].setString(control);
		
	}
	
}

